package com.scgl.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.scgl.order.domain.ScglMation;
import com.scgl.order.service.IScglMationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 生产计划产品信息Controller
 *
 * @author ruoyi
 * @date 2024-10-29
 */
@RestController
@RequestMapping("/mation")
public class ScglMationController extends BaseController
{
    @Autowired
    private IScglMationService scglMationService;

    /**
     * 查询生产计划产品信息列表
     */
    @RequiresPermissions("order:mation:list")
    @GetMapping("/list")
    public TableDataInfo list(ScglMation scglMation)
    {
        startPage();
        List<ScglMation> list = scglMationService.selectScglMationList(scglMation);
        return getDataTable(list);
    }

    /**
     * 导出生产计划产品信息列表
     */
    @RequiresPermissions("order:mation:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScglMation scglMation)
    {
        List<ScglMation> list = scglMationService.selectScglMationList(scglMation);
        ExcelUtil<ScglMation> util = new ExcelUtil<ScglMation>(ScglMation.class);
        util.exportExcel(response, list, "生产计划产品信息数据");
    }

    /**
     * 获取生产计划产品信息详细信息
     */
    @RequiresPermissions("order:mation:query")
    @GetMapping(value = "/{ductId}")
    public AjaxResult getInfo(@PathVariable("ductId") Long ductId)
    {
        return success(scglMationService.selectScglMationByDuctId(ductId));
    }

    /**
     * 新增生产计划产品信息
     */
    @RequiresPermissions("order:mation:add")
    @Log(title = "生产计划产品信息新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScglMation scglMation)
    {
        return toAjax(scglMationService.insertScglMation(scglMation));
    }

    /**
     * 修改生产计划产品信息
     */
    @RequiresPermissions("order:mation:edit")
    @Log(title = "生产计划产品信息修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScglMation scglMation)
    {
        return toAjax(scglMationService.updateScglMation(scglMation));
    }

    /**
     * 删除生产计划产品信息
     */
    @RequiresPermissions("order:mation:remove")
    @Log(title = "生产计划产品信息删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ductIds}")
    public AjaxResult remove(@PathVariable Long[] ductIds)
    {
        return toAjax(scglMationService.deleteScglMationByDuctIds(ductIds));
    }
}
